<script>
APP.totalPointUniversitas = {
	action: 'proc/admin/totalPointUniversitas.php',
	periode1: null,
	periode2: null,
	
	load_graph: function (form){
		var showImage = function(){
			if ($('graphContainer').getElement('img').complete) $('graphContainer').tween('opacity',1);	
			else showImage.delay(1000);
		}
			
		$('graphContainer').tween('opacity',0);	
		FBModal_loading("Loading...", "Generating graph", true, true);
		form.set('action',APP.totalPointUniversitas.action).set('send',{
			onSuccess: function(res){
				//alert(res);
				if (res) {
					res = res.replace(/href/gi,'onclick');
					$('graphContainer').empty().set('html', res)
						.getElements('area').each(function(item){
							item.addEvent('click', function(e){ new Event(e).stop(); })
								.href="#";
						});
				}
				showImage.delay(1000);
				FBModal_hide();
			}		 
		}).send();
		
	},
	
	load_drillGraph: function (data){
		var proc = data.type==1?
			"proc=graph-drill-departemen&startPeriode="+data.startPeriode+"&endPeriode="+data.endPeriode+
				"&departemenID="+data.departemenID: 
			"proc=graph-drill-all&startPeriode="+data.startPeriode+"&endPeriode="+data.endPeriode
		FBModal_show2( APP.totalPointUniversitas.action , 'post', proc, true, true, null);
	}
};
	
	window.addEvent('domready', function(){
		var form = $('totalPointUniversitas-form');
		load_graph(form);
		APP.totalPointUniversitas.periode1 = dtpicker_attach0(form.periode1, {timePicker:false, format: 'F-Y', 
			maxDate: { date: <?php echo time()?>, format: 'U' },
			onClose: function(){ 
				APP.totalPointUniversitas.periode2.options.minDate = {date:APP.totalPointUniversitas.periode1.attachTo.value, format:'U'};
				APP.totalPointUniversitas.periode2.formatMinMaxDates();
				APP.totalPointUniversitas.load_graph(form);
			}
		});
		APP.totalPointUniversitas.periode2 = dtpicker_attach0(form.periode2, {maxDate:{ date: <?php echo time()?>, format: 'U' }, 
			timePicker:false, format: 'F-Y', onClose: function(){ APP.totalPointUniversitas.load_graph(form); } 
		});
		APP.totalPointUniversitas.periode2.options.minDate = {date:APP.totalPointUniversitas.periode1.attachTo.value, format:'U'};
	});
</script>	
<form id="totalPointUniversitas-form" name="totalPointUniversitas-form" method="post">
<input type="hidden" name="proc" value="graph" />
<table width="100%" border="0">
<tr>
    <td align="right" valign="top" width="100">Departemen : </td>
	<td>
		<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #3366CC;" bgcolor="#FFFFFF">
		<?php $DEP = departemen_select(false, "NAMA_DEPARTMENT ASC"); $row=true; ?>
		<?php while ($row):?>
		<tr <?php echo tag_zebra($z++)?>>
			<?php for($i=0; $i<3; $i++): ?>
			<?php if ($row = mysql_fetch_assoc($DEP)) : ?>
			<td>
			<input name="departemenID[]" type="checkbox" value="<?php echo $row['ID_DEPARTMENT']?>" onChange="load_graph($(this).getParent('form'))"/>
			<span class="marginL5"><?php echo $row['NAMA_DEPARTMENT']?></span>
			</td>
			<?php else: ?><td></td>
			<?php endif;?>
			<?php endfor;?>
		</tr>
		<?php endwhile; ?>
		</table>
	</td>
</tr>
<tr>
    <td align="right">Periode : </td>
    <td><input type="text" id="periode1" name="periode1" value="<?php echo time()?>" /> - <input id="periode2" name="periode2" type="text" value="<?php echo time()?>" /></td>
</tr>
</table>
</form>
